package com.a2j.beans.base;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Date;

/**
 * Author: bzb
 * Data: 2021/10/19 10:04
 * Desc: AppUser和SystemUser基类
 */
@Data
@SuperBuilder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class BaseUser {

    @ApiModelProperty(value = "用户ID")
    private Integer id; // 用户ID

    @ApiModelProperty(value = "手机号", required = true)
    private String phone; // 手机号

    @ApiModelProperty(value = "用户名", required = true)
    private String username; // 用户名

    @ApiModelProperty(value = "用户开关")
    private Integer enable; // 用户开关

    // 密码为特殊字段，不能返回到前端，但也不能直接用JsonIgnore标记，
    // 否则会在调用传递字段时也不赋值，因此需要在返回时手动置空，且配合NUll时不返回给前端
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @ApiModelProperty(value = "密码", required = true)
    private String password; // 密码

    // 忽略返回到json数据中，隐藏属性
    @JsonIgnore
    @ApiModelProperty(value = "盐值")
    private String salt; // 盐值

    @ApiModelProperty(value = "真实姓名")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String realName; // 真实姓名

    @ApiModelProperty(value = "年龄")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer age; // 年龄

    @ApiModelProperty(value = "性别")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer gender; // 性别

    @ApiModelProperty(value = "邮箱")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String email; // 邮箱

    @ApiModelProperty(value = "身份证号码")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String idCard; // 身份证号码

    @ApiModelProperty(value = "身份证照片")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String idCardPic; // 身份证照片

    @ApiModelProperty(value = "头像")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String portrait; // 头像

    @ApiModelProperty(value = "创建时间")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonFormat(pattern = "YYYY-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createDate; // 创建时间

    @ApiModelProperty(value = "最后登录时间")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonFormat(pattern = "YYYY-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastLoginTime; // 最后登录时间
}
